package com.zzyl.controller;

import com.aliyun.iot20180120.models.QueryDeviceDetailRequest;
import com.aliyun.iot20180120.models.QueryDevicePropertyStatusRequest;
import com.aliyun.iot20180120.models.QueryThingModelPublishedRequest;
import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.DeviceDto;
import com.zzyl.dto.DevicePageQueryDto;
import com.zzyl.entity.Device;
import com.zzyl.service.DeviceService;
import com.zzyl.vo.DeviceVo;
import com.zzyl.vo.ProductVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/iot")
public class DeviceController extends BaseController{
    @Autowired
    private DeviceService deviceService;
    @PostMapping("/syncProductList")
    public ResponseResult syncProductList(){
        deviceService.syncProductList();
        return success();
    }
    @GetMapping("/allProduct")
    public ResponseResult<List<ProductVo>> allProduct(){
        List<ProductVo> list=deviceService.allProduct();
        return success(list);
    }
    @PostMapping("/RegisterDevice")
    public ResponseResult registerDevice(@RequestBody DeviceDto deviceDto){
        deviceService.registerDevice(deviceDto);
        return success();
    }
    @GetMapping("/pageQueryDevice")
    public ResponseResult<PageResponse<DeviceVo>> pageQueryDevice(DevicePageQueryDto devicePageQueryDto){
        PageResponse<DeviceVo> pageResponse=deviceService.pageQueryDevice(devicePageQueryDto);
        return success(pageResponse);
    }
    @PostMapping("/QueryDeviceDetail")
    public ResponseResult<DeviceVo> QueryDeviceDetail(@RequestBody QueryDeviceDetailRequest request){
        DeviceVo deviceVo=deviceService.QueryDeviceDetail(request);
        return success(deviceVo);
    }
    @PostMapping("/QueryDevicePropertyStatus")
    public ResponseResult QueryDevicePropertyStatus(@RequestBody QueryDevicePropertyStatusRequest request){
        return deviceService.QueryDevicePropertyStatus(request);

    }

    @PostMapping("/QueryThingModelPublished")
    public ResponseResult QueryDevicePropertyStatus(@RequestBody QueryThingModelPublishedRequest request){
        return deviceService.QueryThingModelPublished(request);

    }


}
